21. Exercise: Resolve Conflicts
Create an SQLite database for Sunshine
In this final exercise for this lesson, you are required to update the database schema again to resolve conflicts, that is to make sure no duplicate dates exist in the database.
To do so, simple add a UNIQUE constraint on the date column to replace on conflict, this will replace an old record with a new record if the date is the same but the remaining columns are different.
Again, don't forget to increment the database version from 2 to 3 now since we've changed it again.
Exercise Code
Exercise: S07.03-Exercise-ConflictResolutionPolicy
SOLUTION:
- Add a UNIQUE constraint on the date column to replace on conflict
- Increment the database version after changing the create table statement